home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / basetyps.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  9.1 KB  |  255 lines

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright (C) Microsoft Corporation, 1992-1996.
  5. //
  6. //  File:       basetyps.h
  7. //
  8. //----------------------------------------------------------------------------
  9.  
  10. /*
  11.  *      C/C++ Run Time Library - Version 9.0
  12.  *
  13.  *      Copyright (c) 1995, 1998 by Borland International
  14.  *      All Rights Reserved.
  15.  *
  16.  */
  17.  
  18. #ifndef _BASETYPS_H_
  19. #define _BASETYPS_H_
  20. #pragma option push -b
  21.  
  22. // Common macros gleamed from COMPOBJ.H
  23.  
  24. #ifdef __cplusplus
  25.     #define EXTERN_C    extern "C"
  26. #else
  27.     #define EXTERN_C    extern
  28. #endif
  29.  
  30. #if defined(_WIN32) /* && !defined(__BORLANDC__) */
  31.  
  32. // Win32 doesn't support __export
  33.  
  34. #define STDMETHODCALLTYPE       __stdcall
  35. #define STDMETHODVCALLTYPE      __cdecl
  36.  
  37. #define STDAPICALLTYPE          __stdcall
  38. #define STDAPIVCALLTYPE         __cdecl
  39.  
  40. #else
  41.  
  42. #define STDMETHODCALLTYPE       __export __stdcall
  43. #define STDMETHODVCALLTYPE      __export __cdecl
  44.  
  45. #define STDAPICALLTYPE          __export __stdcall
  46. #define STDAPIVCALLTYPE         __export __cdecl
  47.  
  48. #endif
  49.  
  50. #define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
  51. #define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE
  52.  
  53. #define STDMETHODIMP            HRESULT STDMETHODCALLTYPE
  54. #define STDMETHODIMP_(type)     type STDMETHODCALLTYPE
  55.  
  56. // The 'V' versions allow Variable Argument lists.
  57.  
  58. #define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
  59. #define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE
  60.  
  61. #define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
  62. #define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE
  63.  
  64.  
  65.  
  66.  
  67. /****** Interface Declaration ***********************************************/
  68.  
  69. /*
  70.  *      These are macros for declaring interfaces.  They exist so that
  71.  *      a single definition of the interface is simulataneously a proper
  72.  *      declaration of the interface structures (C++ abstract classes)
  73.  *      for both C and C++.
  74.  *
  75.  *      DECLARE_INTERFACE(iface) is used to declare an interface that does
  76.  *      not derive from a base interface.
  77.  *      DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface
  78.  *      that does derive from a base interface.
  79.  *
  80.  *      By default if the source file has a .c extension the C version of
  81.  *      the interface declaratations will be expanded; if it has a .cpp
  82.  *      extension the C++ version will be expanded. if you want to force
  83.  *      the C version expansion even though the source file has a .cpp
  84.  *      extension, then define the macro "CINTERFACE".
  85.  *      eg.     cl -DCINTERFACE file.cpp
  86.  *
  87.  *      Example Interface declaration:
  88.  *
  89.  *          #undef  INTERFACE
  90.  *          #define INTERFACE   IClassFactory
  91.  *
  92.  *          DECLARE_INTERFACE_(IClassFactory, IUnknown)
  93.  *          {
  94.  *              // *** IUnknown methods ***
  95.  *              STDMETHOD(QueryInterface) (THIS_
  96.  *                                        REFIID riid,
  97.  *                                        LPVOID FAR* ppvObj) PURE;
  98.  *              STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  99.  *              STDMETHOD_(ULONG,Release) (THIS) PURE;
  100.  *
  101.  *              // *** IClassFactory methods ***
  102.  *              STDMETHOD(CreateInstance) (THIS_
  103.  *                                        LPUNKNOWN pUnkOuter,
  104.  *                                        REFIID riid,
  105.  *                                        LPVOID FAR* ppvObject) PURE;
  106.  *          };
  107.  *
  108.  *      Example C++ expansion:
  109.  *
  110.  *          struct FAR IClassFactory : public IUnknown
  111.  *          {
  112.  *              virtual HRESULT STDMETHODCALLTYPE QueryInterface(
  113.  *                                                  IID FAR& riid,
  114.  *                                                  LPVOID FAR* ppvObj) = 0;
  115.  *              virtual HRESULT STDMETHODCALLTYPE AddRef(void) = 0;
  116.  *              virtual HRESULT STDMETHODCALLTYPE Release(void) = 0;
  117.  *              virtual HRESULT STDMETHODCALLTYPE CreateInstance(
  118.  *                                              LPUNKNOWN pUnkOuter,
  119.  *                                              IID FAR& riid,
  120.  *                                              LPVOID FAR* ppvObject) = 0;
  121.  *          };
  122.  *
  123.  *          NOTE: Our documentation says '#define interface class' but we use
  124.  *          'struct' instead of 'class' to keep a lot of 'public:' lines
  125.  *          out of the interfaces.  The 'FAR' forces the 'this' pointers to
  126.  *          be far, which is what we need.
  127.  *
  128.  *      Example C expansion:
  129.  *
  130.  *          typedef struct IClassFactory
  131.  *          {
  132.  *              const struct IClassFactoryVtbl FAR* lpVtbl;
  133.  *          } IClassFactory;
  134.  *
  135.  *          typedef struct IClassFactoryVtbl IClassFactoryVtbl;
  136.  *
  137.  *          struct IClassFactoryVtbl
  138.  *          {
  139.  *              HRESULT (STDMETHODCALLTYPE * QueryInterface) (
  140.  *                                                  IClassFactory FAR* This,
  141.  *                                                  IID FAR* riid,
  142.  *                                                  LPVOID FAR* ppvObj) ;
  143.  *              HRESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ;
  144.  *              HRESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ;
  145.  *              HRESULT (STDMETHODCALLTYPE * CreateInstance) (
  146.  *                                                  IClassFactory FAR* This,
  147.  *                                                  LPUNKNOWN pUnkOuter,
  148.  *                                                  IID FAR* riid,
  149.  *                                                  LPVOID FAR* ppvObject);
  150.  *              HRESULT (STDMETHODCALLTYPE * LockServer) (
  151.  *                                                  IClassFactory FAR* This,
  152.  *                                                  BOOL fLock);
  153.  *          };
  154.  */
  155.  
  156.  
  157. #if defined(__cplusplus) && !defined(CINTERFACE)
  158. //#define interface               struct FAR
  159. #define interface struct
  160. #define STDMETHOD(method)       virtual HRESULT STDMETHODCALLTYPE method
  161. #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
  162. #define PURE                    = 0
  163. #define THIS_
  164. #define THIS                    void
  165. #define DECLARE_INTERFACE(iface)    interface iface
  166. #define DECLARE_INTERFACE_(iface, baseiface)    interface iface : public baseiface
  167.  
  168.  
  169.  
  170. #else
  171.  
  172. #define interface               struct
  173.  
  174. #define STDMETHOD(method)       HRESULT (STDMETHODCALLTYPE * method)
  175. #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
  176.  
  177.  
  178.  
  179.  
  180. #define PURE
  181. #define THIS_                   INTERFACE FAR* This,
  182. #define THIS                    INTERFACE FAR* This
  183. #ifdef CONST_VTABLE
  184. #define DECLARE_INTERFACE(iface)    typedef interface iface { \
  185.                                     const struct iface##Vtbl FAR* lpVtbl; \
  186.                                 } iface; \
  187.                                 typedef const struct iface##Vtbl iface##Vtbl; \
  188.                                 const struct iface##Vtbl
  189. #else
  190. #define DECLARE_INTERFACE(iface)    typedef interface iface { \
  191.                                     struct iface##Vtbl FAR* lpVtbl; \
  192.                                 } iface; \
  193.                                 typedef struct iface##Vtbl iface##Vtbl; \
  194.                                 struct iface##Vtbl
  195. #endif
  196. #define DECLARE_INTERFACE_(iface, baseiface)    DECLARE_INTERFACE(iface)
  197.  
  198. #endif
  199.  
  200. // macros to define byte pattern for a GUID.
  201. //      Example: DEFINE_GUID(GUID_XXX, a, b, c, ...);
  202. //
  203. // Each dll/exe must initialize the GUIDs once.  This is done in one of
  204. // two ways.  If you are not using precompiled headers for the file(s) which
  205. // initializes the GUIDs, define INITGUID before including compobj.h.  This
  206. // is how OLE builds the initialized versions of the GUIDs which are included
  207. // in ole2.lib.  The GUIDs in ole2.lib are all defined in the same text
  208. // segment GUID_TEXT.
  209. //
  210. // The alternative (which some versions of the compiler don't handle properly;
  211. // they wind up with the initialized GUIDs in a data, not a text segment),
  212. // is to use a precompiled version of compobj.h and then include initguid.h
  213. // after compobj.h followed by one or more of the guid defintion files.
  214.  
  215. #ifndef INITGUID
  216. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  217.     EXTERN_C const GUID FAR name
  218. #else
  219.  
  220. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  221.         EXTERN_C const GUID name \
  222.                 = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
  223. #endif // INITGUID
  224.  
  225. #define DEFINE_OLEGUID(name, l, w1, w2) \
  226.     DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
  227.  
  228. #ifndef _ERROR_STATUS_T_DEFINED
  229. typedef unsigned long error_status_t;
  230. #define _ERROR_STATUS_T_DEFINED
  231. #endif
  232.  
  233. // Borland C++ : wchar_t is standard C++ type
  234. #if !defined(__cplusplus) || !defined(__BORLANDC__)
  235. #ifndef _WCHAR_T_DEFINED
  236. typedef unsigned short wchar_t;
  237. #define _WCHAR_T_DEFINED
  238. #endif
  239. #endif
  240.  
  241. #ifndef GUID_DEFINED
  242. #define GUID_DEFINED
  243. typedef struct _GUID
  244. {
  245.     unsigned long Data1;
  246.     unsigned short Data2;
  247.     unsigned short Data3;
  248.     unsigned char Data4[8];
  249. } GUID;
  250. #endif /* GUID_DEFINED */
  251.  
  252.  
  253. #pragma option pop
  254. #endif
  255.